public class demo1 {
    public String convert(String s, int numRows) {
        int row=2*numRows-2;
        int n=s.length();
        StringBuilder stringBuilder=new StringBuilder();
        //处理第一行
        for (int i = 0; i <n ; i+=row) {
            stringBuilder.append(s.charAt(i));
        }
        //处理中间行
        for (int i = 1; i <numRows ; i++) {
           for(int j=i;j<n;j+=row){
               stringBuilder.append(s.charAt(j));
               stringBuilder.append(s.charAt(numRows-j));
           }
        }
        return stringBuilder.toString();
    }
}
